I chose this topic because I saw a graph of the violence in Nigeria presented by The Economist, which made me realize that the violence might be connected to rising inflation and general food prices.
Inflation is a serious challenge that affects everyone. It may also contribute to the unrest and violence that we witness in some countries, such as Nigeria. Climate change is another urgent issue that cannot be overlooked, especially since it will have disproportionate impacts on the working class of the global south, with global repercussions on the economies of the world, due to globalization. For example, in Nigeria, people spend 97.4% of their income on food. Inflation also has differential effects on various segments of the population, which affects their employment and access to basic needs.
I want to see if violence in Nigeria is in any way correlated with the rise in inflation and food prices, as well as the FX rate changes. I also wanted to see if these variables can be used to predict violence in the future.
This data is from the Nigerian government. I cleaned the data in Excel and saved it as a .csv file to then import into RStudio.
I began by checking the data and removing the months, years, and dates to replace them with a time series formula. To avoid dealing with null values, I began the time series in 2004 and ended it in October 2024.
head(nigeria)
## Year Month Date All.Items Food USDFX violence
## 1 2004 Jan 1/1/2004 22.4 11.9 136.08 18
## 2 2004 Feb 2/1/2004 24.8 14.5 135.16 13
## 3 2004 Mar 3/1/2004 22.5 15.6 134.47 30
## 4 2004 Apr 4/1/2004 17.5 14.4 133.51 32
## 5 2004 May 5/1/2004 19.8 18.1 133.01 17
## 6 2004 Jun 6/1/2004 14.1 14.5 132.75 11
# checking variable type
str(nigeria)
## 'data.frame': 238 obs. of 7 variables:
## $ Year : int 2004 2004 2004 2004 2004 2004 2004 2004 2004 2004 ...
## $ Month : chr "Jan" "Feb" "Mar" "Apr" ...
## $ Date : chr "1/1/2004" "2/1/2004" "3/1/2004" "4/1/2004" ...
## $ All.Items: num 22.4 24.8 22.5 17.5 19.8 14.1 10.7 13 9.1 10.7 ...
## $ Food : num 11.9 14.5 15.6 14.4 18.1 14.5 12.2 16.3 14.6 15.4 ...
## $ USDFX : num 136 135 134 134 133 ...
## $ violence : int 18 13 30 32 17 11 10 16 18 10 ...
ts.nigeria <- nigeria
ts.nigeria$Year <-NULL
ts.nigeria$Date <- NULL
ts.nigeria$Month <-NULL
tseries <- ts(ts.nigeria, start = c(2004,1),frequency = 12)
summary(tseries)
## All.Items Food USDFX violence
## Min. : 3.000 Min. :-3.70 Min. :117.7 Min. : 3.00
## 1st Qu.: 9.425 1st Qu.:10.03 1st Qu.:138.5 1st Qu.: 15.00
## Median :12.230 Median :13.89 Median :154.8 Median : 57.50
## Mean :13.009 Mean :14.32 Mean :231.3 Mean : 93.54
## 3rd Qu.:15.908 3rd Qu.:18.00 3rd Qu.:305.8 3rd Qu.:124.50
## Max. :28.200 Max. :38.50 Max. :795.9 Max. :338.00
I then plotted the variables on a single graph. The variables I looked at were the dollar’s value against the Naira, food inflation and general inflation, which are the small lines, and the total number of acts of political violence each month.
I also plotted each variable separately to better understand the series’ patterns. I saw that there was generally an increase in each category.
The value of dollar has had the most steady increase with a very sharp increase corresponding with the recent election and decision to let the currency “float” and be determined soley by market activity.
I then visualized the relationships using pairs() and
plotted a correlation matrix. From this plot, I can see that there is a
strong relationship between food and general inflation which I will
ignore since food inflation is a factor of general inflation. After
that, USDFX and violence have a strong relationship. From the
correlation plot, violence, and food inflation seem to be the least
correlated.
pairs(tseries)
I then decided to use a linear regression model to see if inflation, food inflation, USD rates had any effect on the rate of violence that occurred. The overall model had an r^{2} of 77% and a small p-value, which is decent but not the best. From the model, I gathered the by p-value, t-value, and standard error, USD increases had a positive effect on the rate of violence, which is bad, and I hope something changes with the way they are handling the currency and the other variables that are affecting the rate of violence in the country. It was, however, somewhat of a surprise that the model showed a negative relationship with inflation. This is surprising the me since it has been reported that Nigerians spend 96% of their income on food supplies. I don’t know how to explain that, but I do know that the value of the dollar is followed closely by merchants and sellers of various items.
lm.violence <- lm(violence~., data=tseries)
lm.violence
##
## Call:
## lm(formula = violence ~ ., data = tseries)
##
## Coefficients:
## (Intercept) All.Items Food USDFX
## -47.1353 -3.5806 1.6735 0.7059
summary(lm.violence)
##
## Call:
## lm(formula = violence ~ ., data = tseries)
##
## Residuals:
## Min 1Q Median 3Q Max
## -175.57 -22.76 -7.55 24.35 133.13
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -47.13528 9.04677 -5.210 4.14e-07 ***
## All.Items -3.58062 1.51226 -2.368 0.0187 *
## Food 1.67349 1.14246 1.465 0.1443
## USDFX 0.70595 0.03078 22.938 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 47.52 on 234 degrees of freedom
## Multiple R-squared: 0.7711, Adjusted R-squared: 0.7682
## F-statistic: 262.8 on 3 and 234 DF, p-value: < 2.2e-16
I then plotted the linear regression. The residual v fitted is curved with a significant number of outliers and appears to signify a nonlinear relationship of the predictors. This model doesn’t seem to be that good when looking at the q-q plot as it indicates a lack of normality. Therefore, I don’t think linear regression is good for modeling. I will now use methods specifically for time series.
## 2.5 % 97.5 %
## (Intercept) -64.9588091 -29.3117440
## All.Items -6.5600192 -0.6012305
## Food -0.5773275 3.9243025
## USDFX 0.6453115 0.7665798
I first decomposed the variables together and seperately.
decom <- decompose(tseries, type = "mult")
Then, I viewed the auto correlation present in the data. From the above graphs of the individual data, the variables seem to be nonstationary, so they depend on time. I also performed the box test, and the p-values were very small, so I can conclude that the data is nonstationary. But I don’t think there is much seasonality outside of the inflations.
I also performed the Box-Pierce test and Augmented Dickey-Fuller test to test the stationarity of the variables. They were not stationary.
# box test
Box.test(tseries[,"All.Items"])
##
## Box-Pierce test
##
## data: tseries[, "All.Items"]
## X-squared = 206.09, df = 1, p-value < 2.2e-16
Box.test(tseries[,"violence"])
##
## Box-Pierce test
##
## data: tseries[, "violence"]
## X-squared = 220.43, df = 1, p-value < 2.2e-16
Box.test(tseries[,"Food"])
##
## Box-Pierce test
##
## data: tseries[, "Food"]
## X-squared = 202.26, df = 1, p-value < 2.2e-16
Box.test(tseries[,"USDFX"]) #none are stationary
##
## Box-Pierce test
##
## data: tseries[, "USDFX"]
## X-squared = 214.99, df = 1, p-value < 2.2e-16
#adf test to see if it is stationary
adf.test(tseries[,"All.Items"])
##
## Augmented Dickey-Fuller Test
##
## data: tseries[, "All.Items"]
## Dickey-Fuller = -2.1882, Lag order = 6, p-value = 0.4967
## alternative hypothesis: stationary
adf.test(tseries[,"violence"])
##
## Augmented Dickey-Fuller Test
##
## data: tseries[, "violence"]
## Dickey-Fuller = -1.8235, Lag order = 6, p-value = 0.6501
## alternative hypothesis: stationary
adf.test(tseries[,"Food"])
##
## Augmented Dickey-Fuller Test
##
## data: tseries[, "Food"]
## Dickey-Fuller = -3.1911, Lag order = 6, p-value = 0.09011
## alternative hypothesis: stationary
adf.test(tseries[,"USDFX"]) # none are stationary
## Warning in adf.test(tseries[, "USDFX"]): p-value greater than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: tseries[, "USDFX"]
## Dickey-Fuller = 1.1484, Lag order = 6, p-value = 0.99
## alternative hypothesis: stationary
So, I second order differenced all the variables for a new acf plot that looks more stationary and lagged them by a few years. The diagonal ones are the ones to look at.
dUSDFX<-diff(tseries[,"USDFX"], differences =2.4, lag = 72) #lagging to 2016
dFood<-diff(tseries[,"Food"], differences =2.4, lag = 72)
dviolence<-diff(tseries[,"violence"], differences =2.4, lag=72)
dInflation<-diff(tseries[,"All.Items"], differences =2.4, lag = 72) #diffed everything twice to make mroe stationary and made new TS
difftseries <- cbind("violence" = dviolence, "All.Items" = dInflation,
"Food" = dFood, "USDFX" = dUSDFX)
After differencing and lagging, the models I made passed the Ljung-Box test.
I then modeled the variables.
mymodel <-auto.arima(difftseries[,"violence"])
mymodel2 <-auto.arima(difftseries[,"All.Items"])
mymodel3 <-auto.arima(difftseries[,"USDFX"])
mymodel4 <-auto.arima(difftseries[,"Food"])
checkresiduals(mymodel)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(1,1,1) with drift
## Q* = 15.254, df = 17, p-value = 0.5772
##
## Model df: 2. Total lags used: 19
checkresiduals(mymodel2)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(1,0,0)(2,0,1)[12] with non-zero mean
## Q* = 7.7666, df = 15, p-value = 0.9328
##
## Model df: 4. Total lags used: 19
checkresiduals(mymodel3)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(1,0,1)(1,0,0)[12] with non-zero mean
## Q* = 24.299, df = 16, p-value = 0.08317
##
## Model df: 3. Total lags used: 19
checkresiduals(mymodel4)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(1,0,1)(2,0,1)[12] with non-zero mean
## Q* = 12.541, df = 14, p-value = 0.5629
##
## Model df: 5. Total lags used: 19
I then forecasted each variable and plotted them.
forecast(mymodel)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Nov 2023 182.0566 128.8663 235.2468 100.70907 263.4041
## Dec 2023 183.2571 123.0390 243.4752 91.16150 275.3527
## Jan 2024 184.8932 121.8297 247.9567 88.44592 281.3405
## Feb 2024 186.6951 121.8463 251.5439 87.51743 285.8727
## Mar 2024 188.5601 122.2729 254.8473 87.18252 289.9377
## Apr 2024 190.4491 122.8584 258.0398 87.07810 293.8202
## May 2024 192.3473 123.5159 261.1788 87.07868 297.6160
## Jun 2024 194.2490 124.2128 264.2852 87.13788 301.3601
## Jul 2024 196.1520 124.9367 267.3673 87.23759 305.0664
## Aug 2024 198.0555 125.6823 270.4288 87.37019 308.7409
## Sep 2024 199.9592 126.4470 273.4714 87.53200 312.3865
## Oct 2024 201.8630 127.2295 276.4965 87.72088 316.0051
## Nov 2024 203.7668 128.0287 279.5049 87.93533 319.5983
## Dec 2024 205.6706 128.8438 282.4974 88.17414 323.1671
## Jan 2025 207.5744 129.6742 285.4747 88.43624 326.7126
## Feb 2025 209.4783 130.5191 288.4374 88.72067 330.2359
## Mar 2025 211.3821 131.3781 291.3861 89.02654 333.7376
## Apr 2025 213.2859 132.2505 294.3213 89.35301 337.2188
## May 2025 215.1897 133.1359 297.2435 89.69930 340.6802
## Jun 2025 217.0935 134.0338 300.1533 90.06469 344.1224
## Jul 2025 218.9974 134.9438 303.0510 90.44849 347.5462
## Aug 2025 220.9012 135.8653 305.9371 90.85006 350.9523
## Sep 2025 222.8050 136.7981 308.8119 91.26878 354.3412
## Oct 2025 224.7088 137.7417 311.6760 91.70408 357.7136
forecast(mymodel2)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Nov 2023 5.687796 2.6801481 8.695443 1.087996 10.28760
## Dec 2023 4.650617 0.6156997 8.685535 -1.520257 10.82149
## Jan 2024 3.385081 -1.3120197 8.082182 -3.798515 10.56868
## Feb 2024 3.612021 -1.5542530 8.778296 -4.289113 11.51316
## Mar 2024 3.679486 -1.8336890 9.192661 -4.752187 12.11116
## Apr 2024 5.907101 0.1312310 11.682970 -2.926330 14.74053
## May 2024 7.108951 1.1311397 13.086763 -2.033323 16.25122
## Jun 2024 7.808551 1.6739340 13.943169 -1.573536 17.19064
## Jul 2024 8.320298 2.0630785 14.577518 -1.249293 17.88989
## Aug 2024 6.906945 0.5534109 13.260480 -2.809947 16.62384
## Sep 2024 6.002336 -0.4270963 12.431768 -3.830632 15.83530
## Oct 2024 5.048848 -1.4404912 11.538187 -4.875740 14.97344
## Nov 2024 5.178889 -1.3827299 11.740507 -4.856241 15.21402
## Dec 2024 5.329523 -1.2893865 11.948432 -4.793225 15.45227
## Jan 2025 5.129199 -1.5352103 11.793609 -5.063136 15.32153
## Feb 2025 5.047631 -1.6531104 11.748373 -5.200269 15.29553
## Mar 2025 4.592558 -2.1371324 11.322248 -5.699615 14.88473
## Apr 2025 5.202899 -1.5498798 11.955677 -5.124585 15.53038
## May 2025 4.833252 -1.9379543 11.604459 -5.522415 15.18892
## Jun 2025 5.250476 -1.5354482 12.036400 -5.127699 15.62865
## Jul 2025 5.254282 -1.5434005 12.051965 -5.141876 15.65044
## Aug 2025 4.767900 -2.0391802 11.574981 -5.642631 15.17843
## Sep 2025 4.303202 -2.5113896 11.117794 -6.118817 14.72522
## Oct 2025 4.014556 -2.8060397 10.835151 -6.416645 14.44576
forecast(mymodel3)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Nov 2023 338.535955 315.09155 361.98036 302.68083 374.3911
## Dec 2023 319.475869 273.10495 365.84679 248.55766 390.3941
## Jan 2024 299.025857 241.40876 356.64296 210.90811 387.1436
## Feb 2024 283.480999 218.87309 348.08891 184.67173 382.2903
## Mar 2024 274.407718 205.13671 343.67873 168.46685 380.3486
## Apr 2024 264.378932 191.89031 336.86755 153.51715 375.2407
## May 2024 255.547254 180.79525 330.29926 141.22393 369.8706
## Jun 2024 152.737574 76.37427 229.10088 35.94998 269.5252
## Jul 2024 42.436069 -35.08333 119.95547 -76.11963 160.9918
## Aug 2024 42.418133 -35.93517 120.77144 -77.41290 162.2492
## Sep 2024 37.271038 -41.68597 116.22805 -83.48329 158.0254
## Oct 2024 11.758399 -67.63680 91.15359 -109.66607 133.1829
## Nov 2024 8.118897 -71.71224 87.95003 -113.97229 130.2101
## Dec 2024 18.215589 -64.15171 100.58289 -107.75432 144.1855
## Jan 2025 29.586389 -54.58561 113.75839 -99.14358 158.3164
## Feb 2025 38.030363 -47.43613 123.49685 -92.67936 168.7401
## Mar 2025 42.470672 -43.92935 128.87070 -89.66677 174.6081
## Apr 2025 47.764337 -39.31143 134.84011 -85.40656 180.9352
## May 2025 52.460149 -35.10605 140.02634 -81.46079 186.3811
## Jun 2025 119.257989 31.33520 207.18077 -15.20831 253.7243
## Jul 2025 191.133159 102.95075 279.31557 56.26980 325.9965
## Aug 2025 190.442431 102.07081 278.81405 55.28970 325.5952
## Sep 2025 193.234239 104.72463 281.74384 57.87048 328.5980
## Oct 2025 209.535704 120.92542 298.14599 74.01796 345.0534
forecast(mymodel4)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Nov 2023 1.36877149 -2.8030837 5.540627 -5.011530 7.749073
## Dec 2023 -0.04566775 -6.3209860 6.229650 -9.642939 9.551603
## Jan 2024 0.38219455 -7.0652371 7.829626 -11.007669 11.772058
## Feb 2024 0.37945776 -7.8203973 8.579313 -12.161138 12.920054
## Mar 2024 3.19446026 -5.5150847 11.904005 -10.125639 16.514560
## Apr 2024 4.55677399 -4.5077302 13.621278 -9.306189 18.419737
## May 2024 8.99338483 -0.3223883 18.309158 -5.253861 23.240630
## Jun 2024 10.12075013 0.6252592 19.616241 -4.401350 24.642850
## Jul 2024 11.09009453 1.4651798 20.715009 -3.629942 25.810131
## Aug 2024 8.87593351 -0.8426190 18.594486 -5.987310 23.739177
## Sep 2024 8.51835455 -1.2681588 18.304868 -6.448826 23.485535
## Oct 2024 7.79018444 -2.0457569 17.626126 -7.252590 22.832959
## Nov 2024 7.19641618 -2.8235823 17.216415 -8.127849 22.520682
## Dec 2024 8.62059648 -1.6768590 18.918052 -7.128003 24.369196
## Jan 2025 9.95956884 -0.5363438 20.455482 -6.092544 26.011682
## Feb 2025 9.73685326 -0.9019817 20.375688 -6.533841 26.007547
## Mar 2025 9.34325889 -1.3989956 20.085513 -7.085602 25.772119
## Apr 2025 10.31015836 -0.5071767 21.127493 -6.233528 26.853845
## May 2025 9.45254142 -1.4194270 20.324510 -7.174699 26.079782
## Jun 2025 11.28125261 0.3694638 22.193041 -5.406888 27.969393
## Jul 2025 11.35406317 0.4132162 22.294910 -5.378518 28.086645
## Aug 2025 9.97828204 -0.9837878 20.940352 -6.786757 26.743321
## Sep 2025 9.04511659 -1.9324631 20.022696 -7.743643 25.833876
## Oct 2025 8.57719803 -2.4117214 19.566117 -8.228904 25.383300
Afterwards, I plotted them one year forward. This is the final model. It seems like violence will still be on the increase. However, dollar hopefully seems to be coming down a well as some disinflation in the overall food inflation.
I chose a lag of 2
lagselect <- VARselect(difftseries, lag.max = 15, type = "const")
lagselect$selection # I CHOSE 2
## AIC(n) HQ(n) SC(n) FPE(n)
## 15 2 1 15
I then created the VAR model with a lag of 2. The R^{2} and the p-values of each are significant, showing that the model is good.
varmod1 <- VAR(difftseries, p=2, type = "const", season = NULL)
summary(varmod1)
##
## VAR Estimation Results:
## =========================
## Endogenous variables: violence, All.Items, Food, USDFX
## Deterministic variables: const
## Sample size: 92
## Log Likelihood: -1324.496
## Roots of the characteristic polynomial:
## 0.8721 0.8721 0.8498 0.7182 0.7182 0.1651 0.1651 0.08503
## Call:
## VAR(y = difftseries, p = 2, type = "const")
##
##
## Estimation results for equation violence:
## =========================================
## violence = violence.l1 + All.Items.l1 + Food.l1 + USDFX.l1 + violence.l2 + All.Items.l2 + Food.l2 + USDFX.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## violence.l1 0.66721 0.10831 6.160 2.49e-08 ***
## All.Items.l1 6.51138 2.66041 2.448 0.0165 *
## Food.l1 -3.44275 1.77448 -1.940 0.0558 .
## USDFX.l1 -0.14963 0.16649 -0.899 0.3714
## violence.l2 0.17585 0.10502 1.674 0.0978 .
## All.Items.l2 -3.66605 2.66302 -1.377 0.1723
## Food.l2 2.25981 1.67970 1.345 0.1822
## USDFX.l2 0.05867 0.17105 0.343 0.7325
## const 22.44916 11.43777 1.963 0.0530 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 43.25 on 83 degrees of freedom
## Multiple R-Squared: 0.7057, Adjusted R-squared: 0.6774
## F-statistic: 24.88 on 8 and 83 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation All.Items:
## ==========================================
## All.Items = violence.l1 + All.Items.l1 + Food.l1 + USDFX.l1 + violence.l2 + All.Items.l2 + Food.l2 + USDFX.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## violence.l1 0.006252 0.006762 0.925 0.3578
## All.Items.l1 0.703358 0.166084 4.235 5.88e-05 ***
## Food.l1 0.251417 0.110777 2.270 0.0258 *
## USDFX.l1 0.009119 0.010393 0.877 0.3828
## violence.l2 -0.008079 0.006556 -1.232 0.2213
## All.Items.l2 0.180516 0.166247 1.086 0.2807
## Food.l2 -0.253914 0.104860 -2.421 0.0176 *
## USDFX.l2 -0.002843 0.010678 -0.266 0.7907
## const -0.124870 0.714035 -0.175 0.8616
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 2.7 on 83 degrees of freedom
## Multiple R-Squared: 0.8609, Adjusted R-squared: 0.8475
## F-statistic: 64.19 on 8 and 83 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Food:
## =====================================
## Food = violence.l1 + All.Items.l1 + Food.l1 + USDFX.l1 + violence.l2 + All.Items.l2 + Food.l2 + USDFX.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## violence.l1 0.008154 0.010550 0.773 0.442
## All.Items.l1 0.068955 0.259126 0.266 0.791
## Food.l1 0.966899 0.172835 5.594 2.77e-07 ***
## USDFX.l1 -0.001120 0.016216 -0.069 0.945
## violence.l2 -0.011587 0.010229 -1.133 0.261
## All.Items.l2 0.187779 0.259380 0.724 0.471
## Food.l2 -0.230027 0.163604 -1.406 0.163
## USDFX.l2 0.007302 0.016660 0.438 0.662
## const 0.160678 1.114045 0.144 0.886
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 4.213 on 83 degrees of freedom
## Multiple R-Squared: 0.8531, Adjusted R-squared: 0.8389
## F-statistic: 60.25 on 8 and 83 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation USDFX:
## ======================================
## USDFX = violence.l1 + All.Items.l1 + Food.l1 + USDFX.l1 + violence.l2 + All.Items.l2 + Food.l2 + USDFX.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## violence.l1 -0.05054 0.06166 -0.820 0.41473
## All.Items.l1 3.20713 1.51444 2.118 0.03719 *
## Food.l1 -1.83326 1.01012 -1.815 0.07315 .
## USDFX.l1 1.37732 0.09477 14.533 < 2e-16 ***
## violence.l2 0.05474 0.05979 0.916 0.36249
## All.Items.l2 -0.72972 1.51593 -0.481 0.63152
## Food.l2 0.47400 0.95617 0.496 0.62139
## USDFX.l2 -0.54077 0.09737 -5.554 3.28e-07 ***
## const 19.55346 6.51097 3.003 0.00353 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 24.62 on 83 degrees of freedom
## Multiple R-Squared: 0.8873, Adjusted R-squared: 0.8764
## F-statistic: 81.65 on 8 and 83 DF, p-value: < 2.2e-16
##
##
##
## Covariance matrix of residuals:
## violence All.Items Food USDFX
## violence 1870.539 -1.4096 -1.486 111.3475
## All.Items -1.410 7.2899 8.795 -0.9724
## Food -1.486 8.7945 17.746 -11.9740
## USDFX 111.347 -0.9724 -11.974 606.1438
##
## Correlation matrix of residuals:
## violence All.Items Food USDFX
## violence 1.000000 -0.01207 -0.008155 0.10457
## All.Items -0.012071 1.00000 0.773226 -0.01463
## Food -0.008155 0.77323 1.000000 -0.11545
## USDFX 0.104570 -0.01463 -0.115453 1.00000
I performed the Portmanteau test and saw no autocorrelation. The ARCH test shows conditional heteroscedasticity. The normality test showed that the data is not normally distributed, and residuals aren’t all in the confidence intervals.
The Granger test shows that violence does not cause the other variables.
serial <- serial.test(varmod1)
serial # pval seems high enough to have no autocorrelation i think
##
## Portmanteau Test (asymptotic)
##
## data: Residuals of VAR object varmod1
## Chi-squared = 217.58, df = 224, p-value = 0.6083
arch <- arch.test(varmod1)
arch # I think this shows heteroscedasticity
##
## ARCH (multivariate)
##
## data: Residuals of VAR object varmod1
## Chi-squared = 521.19, df = 500, p-value = 0.2476
normal <- normality.test(varmod1)
normal
## $JB
##
## JB-Test (multivariate)
##
## data: Residuals of VAR object varmod1
## Chi-squared = 259.27, df = 8, p-value < 2.2e-16
##
##
## $Skewness
##
## Skewness only (multivariate)
##
## data: Residuals of VAR object varmod1
## Chi-squared = 5.7866, df = 4, p-value = 0.2157
##
##
## $Kurtosis
##
## Kurtosis only (multivariate)
##
## data: Residuals of VAR object varmod1
## Chi-squared = 253.48, df = 4, p-value < 2.2e-16
cause.v <- causality(varmod1, cause = "violence")
cause.v
## $Granger
##
## Granger causality H0: violence do not Granger-cause All.Items Food
## USDFX
##
## data: VAR object varmod1
## F-Test = 0.40869, df1 = 6, df2 = 332, p-value = 0.8732
##
##
## $Instant
##
## H0: No instantaneous causality between: violence and All.Items Food
## USDFX
##
## data: VAR object varmod1
## Chi-squared = 1.0385, df = 3, p-value = 0.7919
Afterward, I forecasted a year into the future. I tried the
predict() and forecast() functions.
forecastv <- predict(varmod1, n.ahead = 12, ci=.95)
forecastm <- forecast(varmod1, h =12) #12 mo forecast
Below are the respective forecast plots.
After reviewing the plots of the ARIMA model, I see that violence will rise, but not very drastically. The value of the Dollar against Naira seems to drop dramatically in the next 12 months, which might help point to the new currency rules actually working. Both inflation variables show an overall constant growth that might be eased if the Dollar actually drops.
The VAR model shows a similar pattern but is not as dramatic and is smoother.